using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

using MakeIT.Alf.Site.Entidades;
using MakeIT.Alf.Site.Negocios;

namespace MakeIT.Alf.Site.Apresentacao
{
	public partial class DownImovelxfotoFotoLarge : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

			//Recupera dados
			ImovelxfotoVO imovelxfotoVO = ImovelxfotoVO.CreateVO();
			imovelxfotoVO.idImovelxfoto = Int32.Parse(Request["idImovelxfoto"]);
			AlfDAO.getImovelxfotoFotoLarge(imovelxfotoVO);

			if (imovelxfotoVO.fotoLarge != null)
			{
				Response.ContentType = imovelxfotoVO.fotoLargeMime;
				Response.AppendHeader("Content-Disposition", "attachment; filename=" + imovelxfotoVO.fotoLargeNome);

				Response.BinaryWrite(imovelxfotoVO.fotoLarge);
				return;
			}

			Response.ContentType = "image/png";
			Response.AppendHeader("Content-Disposition", "attachment; filename=SemFoto.png");
			string filePath = HttpContext.Current.Server.MapPath("~/App_Themes/Padrao/Imagens/backoffice/SemFoto.png");
			Response.BinaryWrite(File.ReadAllBytes(filePath));
		}
	}
}
